package com.wf.classRoomTest.exch;


/**
 * @author mpk
 * @since 2024/6/20 14:04:51
 */
public class LogDecorator extends StaticUserSerivceProxy{


    public LogDecorator(IUserService userService) {
        super(userService);
    }

    @Override
    public boolean login(String username, String password) {
        System.out.println("开始日志记录，追踪的方法是login,username="+username);
        long start = System.currentTimeMillis();

        //调用目标对象的相同方法 --核心业务
        boolean result = super.login(username, password);

        long end = System.currentTimeMillis();
        System.out.println("结束日志追踪，，追踪的方法是login,此方法耗时="+(end-start)/1000.0+"s");
        return result;
    }

    @Override
    public boolean register(String username, String password, int age) {
        System.out.println("开始日志记录，追踪的方法是login,username="+username);
        long start = System.currentTimeMillis();

        //调用目标对象的相同方法 --核心业务
        boolean result = super.register(username, password, age);

        long end = System.currentTimeMillis();
        System.out.println("结束日志追踪，，追踪的方法是login,此方法耗时="+(end-start)/1000.0+"s");
        return result;
    }
}
